package cn.kent.high.juc.queue;

import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * ConcurrentLinkedQueue 是线程安全的无界非阻塞队列
 * 底层数据结构：单向链表
 * 入队出队：CAS
 */
public class ConcurrentLinkedQueueTest {
    public static void main(String[] args) {
        ConcurrentLinkedQueue<String> queue = new ConcurrentLinkedQueue<>();
        queue.add("Hello");
        queue.add("Hello2");
        queue.remove("Hello");
        Iterator<String> iterator = queue.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
        System.out.println("peek: "+queue.peek());
        System.out.println("contains: "+queue.contains("Hello"));
    }
}
